package com.eightbears.beboy.base.view.popupwindow;

import android.app.Activity;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.eightbears.beboy.R;
import com.eightbears.beboy.base.view.basepopu.BasePopupWindow;

/**
 * Created by Bao on 2017/5/3.
 */
public class MultipeSelectionPopup extends BasePopupWindow implements View.OnClickListener {

    private View popupView;
    private TextView tx_1, tx_2, tx_3, tx_4, tx_5, tx_6, tx_title;
    private LinearLayout ll_1, ll_2, ll_3, ll_4, ll_5, ll_6, ll_title;

    private OnClicktemListener mOnClicktemListener;


    public MultipeSelectionPopup(Activity context) {
        super(context);
        bindEvent();
    }

    @Override
    public Animation getAnimation() {
        return getDefaultAlphaAnimation();
    }

    @Override
    public AnimationSet getAnimationSet() {
        return null;
    }

    @Override
    public View getInputView() {
        return null;
    }

    @Override
    public View getDismissView() {
        return popupView.findViewById(R.id.click_to_dismiss);
    }

    @Override
    public View getPopupView() {
        popupView = LayoutInflater.from(mContext).inflate(R.layout.view_multipe_select_popup, null);
        return popupView;
    }

    @Override
    public View getAnimaView() {
        return popupView.findViewById(R.id.popup_anima);
    }

    private void bindEvent() {
        if (popupView != null) {
            tx_title = (TextView) popupView.findViewById(R.id.tx_title);
            tx_1 = (TextView) popupView.findViewById(R.id.tx_1);
            tx_2 = (TextView) popupView.findViewById(R.id.tx_2);
            tx_3 = (TextView) popupView.findViewById(R.id.tx_3);
            tx_4 = (TextView) popupView.findViewById(R.id.tx_4);
            tx_5 = (TextView) popupView.findViewById(R.id.tx_5);
            tx_6 = (TextView) popupView.findViewById(R.id.tx_6);

            ll_title = (LinearLayout) popupView.findViewById(R.id.ll_item_title);
            ll_1 = (LinearLayout) popupView.findViewById(R.id.ll_1);
            ll_2 = (LinearLayout) popupView.findViewById(R.id.ll_2);
            ll_3 = (LinearLayout) popupView.findViewById(R.id.ll_3);
            ll_4 = (LinearLayout) popupView.findViewById(R.id.ll_4);
            ll_5 = (LinearLayout) popupView.findViewById(R.id.ll_5);
            ll_6 = (LinearLayout) popupView.findViewById(R.id.ll_6);

            ll_1.setOnClickListener(this);
            ll_2.setOnClickListener(this);
            ll_3.setOnClickListener(this);
            ll_4.setOnClickListener(this);
            ll_5.setOnClickListener(this);
            ll_6.setOnClickListener(this);
        }
    }

    public void setTx_title(String title) {
        if (null != tx_title && !TextUtils.isEmpty(title)) {
            ll_title.setVisibility(View.VISIBLE);
            tx_title.setText(title);
        }

    }

    public void setTx_1Text(String itemText) {
        if (null != tx_1 && !TextUtils.isEmpty(itemText)) {
            ll_1.setVisibility(View.VISIBLE);
            tx_1.setText(itemText);
        }

    }

    public void setTx_2Text(String itemText) {
        if (null != tx_2 && !TextUtils.isEmpty(itemText)) {
            ll_2.setVisibility(View.VISIBLE);
            tx_2.setText(itemText);
        }
    }

    public void setTx_3Text(String itemText) {
        if (null != tx_3 && !TextUtils.isEmpty(itemText)) {
            ll_3.setVisibility(View.VISIBLE);
            tx_3.setText(itemText);
        }
    }

    public void setTx_4Text(String itemText) {
        if (null != tx_4 && !TextUtils.isEmpty(itemText)) {
            ll_4.setVisibility(View.VISIBLE);
            tx_4.setText(itemText);
        }
    }

    public void setTx_5Text(String itemText) {
        if (null != tx_5 && !TextUtils.isEmpty(itemText)) {
            ll_5.setVisibility(View.VISIBLE);
            tx_5.setText(itemText);
        }
    }
    public void setTx_6Text(String itemText) {
        if (null != tx_6 && !TextUtils.isEmpty(itemText)) {
            ll_6.setVisibility(View.VISIBLE);
            tx_6.setText(itemText);
        }
    }

    @Override
    public void onClick(View v) {
        mOnClicktemListener.onClickItem(v);
    }

    public interface OnClicktemListener {
        void onClickItem(View v);
    }

    public void setOnClickItemListener(OnClicktemListener onClickItemListener) {
        this.mOnClicktemListener = onClickItemListener;
    }
}
